﻿#include "CloudMainWindow.h"
#include "ui_CloudMainWindow.h"
#include <QDebug>

CloudMainWindow::CloudMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::CloudMainWindow)
{
    ui->setupUi(this);
}

CloudMainWindow::~CloudMainWindow()
{
    delete ui;
}

void CloudMainWindow::signInInitHandle(QString mesg)
{
    qDebug() << "signInInitHandle signInInitHandle ";
    //登录成功，显示窗口
    show();
    //更具服务器初始化数据，初始化界面
    //username@account>:Friendname@account#Friendname@account#...
    //初始化个人信息
    auto mesgSplitList = mesg.split(">:");
    QString user = mesgSplitList.at(0);
    this->username = user.split("@").at(0);
    this->account = user.split('@').at(1);
    this->setWindowTitle(QString("CloudDisk-%1").arg(username));
    //初始化好友消息界面
    if(mesgSplitList.at(1) == "")
    {
        return;
    }
    QString friends = mesgSplitList.at(1);
    auto friendList = friends.split('#');
    foreach(auto itm, friendList)
    {
        //初始化好友列表
        if(itm == "")
        {
            continue;
        }
        QString friendName = itm.split('@').at(0);
        QString friendAccount = itm.split('@').at(1);
        addListAndStackedWidget(friendName, friendAccount);
    }
}

void CloudMainWindow::displayRecMesgHandle(QString targetAccount, QString payload)
{

}

void CloudMainWindow::newFriendHandle(QString friendAccountInfo)
{

}

void CloudMainWindow::faildAddFriendHandle(QString friendAccount)
{

}

void CloudMainWindow::aboutAirChat()
{

}

void CloudMainWindow::addFriendHandle(QString friendAccount)
{

}

//void CloudMainWindow::on_listWidgetFriend_currentRowChanged(int currentRow)
//{

//}

void CloudMainWindow::sendMesgHandle(QString targetAccount, QString payload)
{

}

void CloudMainWindow::addListAndStackedWidget(QString friendName, QString friendAccount)
{

}
